package com.cjxt.ams.utils;

import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;

/**
 * @author JK_a
 * @version V1.0
 * @Description:
 * @className: Result
 * @date 2021/11/19 16:23
 * @company:华勤技术股份有限公司
 * @copyright: Copyright (c) 2021
 */

@Data
public class Result<T>   implements Serializable {

    private int code = 0;
    /**
     * 成功标志
     */
    private boolean success = true;

    private String message="操作成功";
    private T data;

    public static Result ok(String message){
        Result result =new Result();
        result.setMessage(message);
        return result;
    }

    public static Result ok(){
        return new Result();
    }

    public static Result ok(Object objs){
        Result result =new Result();
        result.setData(objs);
        return result;
    }

    public static Result error(int code){
        Result result =new Result();
        result.setSuccess(false);
        result.setMessage("操作失败");
        result.setCode(code);
        return result;
    }

    public static Result error(String message){
        Result result =new Result();
        result.setMessage(message);
        result.setSuccess(false);
        result.setCode(500);
        return result;
    }

    /**
     * 认证失败
     * @param message
     * @return
     */
    public static Result noAuth(String message){
        Result result =new Result();
        result.setMessage(message);
        result.setSuccess(false);
        result.setCode(510);
        return result;
    }
}